package com.bt.lms.service.impl;

import com.bt.lms.constant.BOConstant;
import com.bt.lms.entity.TeacherBasicInfo;
import com.bt.lms.entity.page.Page;
import com.bt.lms.bo.TeacherList;
import com.bt.lms.dao.servise.TeacherBasicInfoDao;
import com.bt.lms.dao.servise.impl.TeacherBasicInfoDaoImpl;
import com.bt.lms.service.TeacherBasicInfoService;

/**
 * 教师管理接口实现
 * @author 李舒淇
 */
public class TeacherBasicInfoServiceImpl implements TeacherBasicInfoService {
    @Override
    public Page<TeacherList> query(Page<TeacherList> page) {
        return null;
    }


    @Override
    public boolean add(TeacherBasicInfo teacherBasicInfo) throws Exception {

        //1.需要系统维护的属性（不是用户直接输入的属性）



        String sql = "insert into teacher_basic_info(account,name,certificate_Type,certificate_Number," +
                "gender,birthdate,birthplace,nation,politics_Status,Learning_Center,specialty," +
                "job_Title,highest_Degree,teaching_Age,phone,research_Interests,picture,on_Job_Status)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.insert(sql,teacherBasicInfo);

        return false;
    }




    @Override
    public boolean edit(Long id,TeacherBasicInfo teacherBasicInfo) throws Exception {

        //1.需要系统维护的属性（不是用户直接输入的属性）

        teacherBasicInfo.setEnableStatus(BOConstant.TEACHER_BASIC_INFO_ENABLE_ENABLE);//启用状态

        String sql = "UPDATE teacher_basic_info set account=?,name=?,certificate_Type=?,certificate_Number=?," +
                "gender=?,birthdate=?,birthplace=?,nation=?,politics_Status=?,Learning_Center=?,specialty=?," +
                "job_Title=?,highest_Degree=?,teaching_Age=?,phone=?,research_Interests=?,picture=? where id=?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.edit(sql,teacherBasicInfo,id);

        return false;
    }


    @Override
    public TeacherBasicInfo details(Long id) throws Exception {

        //sql语句
        String sql = "select * from teacher_basic_info where id=?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        TeacherBasicInfo teacherBasicInfo = new TeacherBasicInfo();
        teacherBasicInfoDao.details(sql,teacherBasicInfo,id);
        return teacherBasicInfo;
    }


    @Override
    public boolean enable(Long id) throws Exception {

        //sql语句
        String sql = "UPDATE teacher_basic_info set enable_status = ? WHERE id =?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.enable(sql,id);

        return false;
    }

    @Override
    public boolean stop(Long id) throws Exception {
        //sql语句
        String sql = "UPDATE teacher_basic_info set enable_status = ? WHERE id=?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.stop(sql,id);
        return false;
    }

    @Override
    public boolean onJob(Long id) throws Exception {
        //sql语句
        String sql = "UPDATE teacher_basic_info set on_job_status = ? WHERE id=?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.onJob(sql,id);
        return false;
    }

    @Override
    public boolean leaveOffice(Long id) throws Exception {
        //sql语句
        String sql = "UPDATE teacher_basic_info set on_job_status = ? ,enable_status = ? WHERE id=?";
        TeacherBasicInfoDao teacherBasicInfoDao = new TeacherBasicInfoDaoImpl();
        teacherBasicInfoDao.leaveOffice(sql,id);
        return false;
    }
}
